home *** CD-ROM | disk | FTP | other *** search
/ Macworld Expo - Develope…Central & Net Innovations / Developer Central and Net Innovators (MacWorld Expo) (January 1999).iso / Developer Central / Bowers Development / Demo AppMaker / Examples / C⁄C++ OS8 / Everything / ModelessButtons.cp < prev    next >
Encoding:
Text File  |  1998-09-06  |  4.8 KB  |  197 lines  |  [TEXT/CWIE]

  1. // ModelessButtons.cp -- modeless dialog
  2.  
  3. #include <Types.h>
  4. #include <Quickdraw.h>
  5. #include <Controls.h>
  6. #include <Dialogs.h>
  7. #include <Events.h>
  8. #include <Lists.h>
  9. #include <Menus.h>
  10. #include <TextEdit.h>
  11. #include <Appearance.h>
  12.  
  13. #include "ResourceDefs.h"
  14. #include "Miscellany.h"
  15. #include "ControlUtils.h"
  16.  
  17. #include "ModelessButtons.h"
  18.  
  19. #define kCapInvisibleLabel        1
  20. #define kInvisibleButton        2
  21. #define kStandardButton        3
  22. #define kDefaultButton        4
  23. #define kBevelBox        5
  24. #define kButtonButton        6
  25. #define kNextButton        7
  26. #define kNext2Button        8
  27. #define kGraphicBox        9
  28. #define kCapcicnLabel        10
  29. #define kRightButton        11
  30. #define kCapicl8Label        12
  31. #define kLightButton        13
  32. #define kCapICNLabel        14
  33. #define kRight2Button        15
  34. #define kCapicl9Label        16
  35. #define kButton2Button        17
  36. #define kRight3Button        18
  37. #define kCapPICTLabel        19
  38. #define kRect3DButton        20
  39. #define kLeftIconButton        21
  40. #define kRightIconButton        22
  41. #define kTitledPICTButton        23
  42.  
  43.  
  44. //----------
  45. CModelessButtons*        CModelessButtons::sDialog = nil;
  46.  
  47. //----------
  48. // static
  49. CModelessButtons*        CModelessButtons::Create ()
  50. {
  51.     CModelessButtons*        dialog = new CModelessButtons;
  52.  
  53.     dialog->MakeDialog (DLOG_ModelessButtons);
  54.  
  55.     return dialog;
  56. }
  57.  
  58. //----------
  59. // static
  60. CModelessButtons*        CModelessButtons::Show ()
  61. {
  62.     if (sDialog == nil) {
  63.         sDialog = CModelessButtons::Create ();
  64.     }
  65.     if (sDialog != nil) {
  66.         ::SelectWindow (sDialog->mDialog);
  67.         ::ShowWindow (sDialog->mDialog);
  68.     }
  69.     return sDialog;
  70. }
  71.  
  72. //----------
  73. CModelessButtons::CModelessButtons ()
  74. {
  75. }
  76.  
  77. //----------
  78. CModelessButtons::~CModelessButtons ()
  79. {
  80.     sDialog = nil;
  81. }
  82.  
  83. //----------
  84. void    CModelessButtons::FinishMake ()
  85. {
  86.     mInvisibleHandle = GetControlItem (kInvisibleButton);
  87.     mStandardHandle = GetControlItem (kStandardButton);
  88.     mDefaultHandle = GetControlItem (kDefaultButton);
  89.     SetDefaultState (mDefaultHandle, true);
  90.     ::SetDialogDefaultItem (mDialog, kDefaultButton);
  91.     mBevelHandle = GetControlItem (kBevelBox);
  92.     mButtonHandle = GetControlItem (kButtonButton);
  93.     SetBevelButtonGraphicAlignment (mButtonHandle, kControlBevelButtonAlignCenter, 0, 0);
  94.     mNextHandle = GetControlItem (kNextButton);
  95.     SetBevelButtonTextPlacement (mNextHandle, kControlBevelButtonPlaceToRightOfGraphic);
  96.     SetBevelButtonTextAlignment (mNextHandle, kControlBevelButtonAlignTextFlushLeft, 0);
  97.     SetBevelButtonGraphicAlignment (mNextHandle, kControlBevelButtonAlignLeft, 0, 0);
  98.     mNext2Handle = GetControlItem (kNext2Button);
  99.     SetBevelButtonTextPlacement (mNext2Handle, kControlBevelButtonPlaceBelowGraphic);
  100.     SetBevelButtonTextAlignment (mNext2Handle, kControlBevelButtonAlignTextCenter, 0);
  101.     SetBevelButtonGraphicAlignment (mNext2Handle, kControlBevelButtonAlignTop, 0, 0);
  102.     mGraphicHandle = GetControlItem (kGraphicBox);
  103.     mRightHandle = GetControlItem (kRightButton);
  104.     mLightHandle = GetControlItem (kLightButton);
  105.     mRight2Handle = GetControlItem (kRight2Button);
  106.     mButton2Handle = GetControlItem (kButton2Button);
  107.     mRight3Handle = GetControlItem (kRight3Button);
  108.     mRect3DHandle = GetControlItem (kRect3DButton);
  109.     mLeftIconHandle = GetControlItem (kLeftIconButton);
  110.     mRightIconHandle = GetControlItem (kRightIconButton);
  111.     mTitledPICTHandle = GetControlItem (kTitledPICTButton);
  112. }
  113.  
  114. //----------
  115. void    CModelessButtons::ConnectToData (
  116.     AMSignaler*        inData)
  117. {
  118.     AMDialog::ConnectToData (inData);
  119.  
  120. }
  121.  
  122. //----------
  123. void    CModelessButtons::DataChanged (
  124.     long        inDataID)
  125. {
  126. }
  127.  
  128.  
  129. //----------
  130. void    CModelessButtons::DoItem (
  131.     SInt16        inItemHit)
  132. {
  133.     switch (inItemHit) {
  134.     case kInvisibleButton:
  135.             //? this button doesn't have a command
  136.             // DoInvisibleButton ();
  137.         break;
  138.     case kStandardButton:
  139.             //? this button doesn't have a command
  140.             // DoStandardButton ();
  141.         break;
  142.     case kDefaultButton:
  143.             //? this button doesn't have a command
  144.             // DoDefaultButton ();
  145.         break;
  146.     case kButtonButton:
  147.             //? this button doesn't have a command
  148.             // DoButtonButton ();
  149.         break;
  150.     case kNextButton:
  151.             //? this button doesn't have a command
  152.             // DoNextButton ();
  153.         break;
  154.     case kNext2Button:
  155.             //? this button doesn't have a command
  156.             // DoNext2Button ();
  157.         break;
  158.     case kRightButton:
  159.             //? this button doesn't have a command
  160.             // DoRightButton ();
  161.         break;
  162.     case kLightButton:
  163.             //? this button doesn't have a command
  164.             // DoLightButton ();
  165.         break;
  166.     case kRight2Button:
  167.             //? this button doesn't have a command
  168.             // DoRight2Button ();
  169.         break;
  170.     case kButton2Button:
  171.             //? this button doesn't have a command
  172.             // DoButton2Button ();
  173.         break;
  174.     case kRight3Button:
  175.             //? this button doesn't have a command
  176.             // DoRight3Button ();
  177.         break;
  178.     case kRect3DButton:
  179.             //? this button doesn't have a command
  180.             // DoRect3DButton ();
  181.         break;
  182.     case kLeftIconButton:
  183.             //? this button doesn't have a command
  184.             // DoLeftIconButton ();
  185.         break;
  186.     case kRightIconButton:
  187.             //? this button doesn't have a command
  188.             // DoRightIconButton ();
  189.         break;
  190.     case kTitledPICTButton:
  191.             //? this button doesn't have a command
  192.             // DoTitledPICTButton ();
  193.         break;
  194.  
  195.     } // switch
  196. }
  197.